package com.hl.sfzy.service.content.impl;

import java.time.LocalDateTime;
import java.util.List;

import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hl.sfzy.entity.content.Knowlege;
import com.hl.sfzy.mapper.content.knowlege.KnowlegeMapper;
import com.hl.sfzy.service.content.KnowledgeService;


@Service
public class KnowledgeServiceImpl implements KnowledgeService{




    @Autowired
    public KnowlegeMapper mapper;

    @Override
    public List<Knowlege> getKnowledges() {
       return mapper.findByAll();
    }
    @Override
    public List<Knowlege> getKnowledgesPage(Integer pageNo,Integer pageSize) {
        PageHelper.startPage(pageNo, pageSize);
        return mapper.findByAll();
    }

    @Override
    public Knowlege getKnowlegeById(Long id) {
        return mapper.findById(id);
    }

    @Override
    public int addKnowlege(Knowlege knowlege) {
        return mapper.saveOne(knowlege);
    }

    @Override
    public List<Knowlege> getKnowlegeByName(String knowlegeName) {
        return mapper.findByName(knowlegeName);
    }

    @Override
    public int removeKnowlege(Long id) {
        return mapper.deleteOne(id);
    }

    @Override
    public int updateKnowlege(Knowlege knowlege) {
        return mapper.updateOne(knowlege);
    }

    @Override
    public List<Knowlege> searchKnowledges(String key, LocalDateTime starTime, LocalDateTime endTime) {
        return mapper.search(key,starTime,endTime);
    }
    
}
